package com.medusa.aps.business.modules.security.controller;

import com.medusa.aps.business.common.model.resp.Result;
import com.medusa.aps.business.model.pagination.Page;
import com.medusa.aps.business.modules.security.model.input.RoleQueryPara;
import com.medusa.aps.business.modules.security.model.output.RoleVO;
import com.medusa.aps.business.modules.security.mp.entity.Role;
import com.medusa.aps.business.modules.security.mp.service.IRoleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 角色控制层
 *
 * @author: yuxh
 * @order 2
 **/
@Slf4j
@RestController
@RequestMapping("/system/role")
@Tag(name = "系统管理-角色表", description = "系统管理-角色表")
public class RoleController {

    @Resource
    private IRoleService roleService;

    /**
     * 获取系统管理-角色表 列表分页
     */
    @GetMapping(value = "/listPage")
    @Operation(summary = "获取系统管理-角色表 列表分页", description = "获取系统管理-角色表 列表分页", tags = {"系统管理-角色表接口"})
    public Result<Page<Role>> listPage(RoleQueryPara roleQueryPara) {
        return Result.ok(roleService.listPage(roleQueryPara), "获取系统管理-角色表 列表分页成功");
    }

    /**
     * 获取所有角色
     *
     * @return 角色列表
     */
    @GetMapping("/selectAll")
    @Operation(summary = "获取所有角色")
    public Result<List<RoleVO>> selectAll() {
        return Result.ok(roleService.selectAll());
    }

    /**
     * 获取角色详情
     *
     * @param roleId 角色id
     */
    @GetMapping("/getRole")
    @Operation(summary = "获取角色详情")
    public Result<RoleVO> getRole(@RequestParam("roleId") Integer roleId) {
        return Result.ok(roleService.getRole(roleId), "获取角色成功");
    }

}
